<template>
  <view>
    <view class="list-container">
      <view class="item">
        <view class="top-label" @click="retractItem">
          <view>配餐单位信息</view>
          <view v-if="viewItem.show"><uv-icon name="arrow-down" size="40rpx" color="#000000"></uv-icon></view>
          <view v-else><uv-icon name="arrow-right" size="40rpx" color="#000000"></uv-icon></view>
        </view>
        <view v-if="viewItem.show" class="info">
          <view class="row">
            <view class="title">配餐单位名称:</view>
            <view class="con">{{ form.name||"--" }}</view>
          </view>
          <view class="row">
            <view class="title">供应餐次:</view>
            <view class="con">{{ form.mealTimesName||"--" }}</view>
          </view>
          <view class="row">
            <view class="title">负责人:</view>
            <view class="con">{{ form.legalPerson||"--" }}</view>
          </view>
          <view class="row">
            <view class="title" style="width: 300rpx;">联系方式:</view>
            <view class="con">{{ form.contactWay||"--" }}</view>
          </view>
          <view class="row">
            <view class="title" style="width: 300rpx;">餐饮风险量化等级：</view>
            <view class="con">{{ form.quantifyGradeName||"--" }}</view>
          </view>
          <view class="row">
            <view class="title">从业人员数量:</view>
            <view class="con">{{ form.employedCount||"--"}}</view>
          </view>
          <view class="row">
            <view class="title" style="width: 300rpx;">是否实施名厨亮灶：</view>
            <view class="con">{{ form.kitchenFlag === 1 ? "是" : "否" }}</view>
          </view>
          <view class="row">
            <view class="title">食品经营许可证编号:</view>
            <view v-if="form.certificate2.length>0" class="con">{{ form.certificate2[0].documentNo }}</view>
            <view v-else class="con">--</view>
          </view>
          <view class="row" style="line-height: 80px">
            <view class="title">食品经营许可证:</view>
            <view class="con" v-if="form.certificate2.length>0"> <fileView v-if="form.certificate2[0].id" style="float: right" :tableId="form.certificate2[0].id"  :width="80" :height="80"></fileView></view>
            <view v-else class="con">--</view>
          </view>
          <view class="row"  style="line-height: 80px">
            <view class="title">中国居民身份证:</view>
            <view v-if="form.certificate3.length>0" class="con" style="display: flex;justify-content: flex-end;">
              <fileView  v-if="form.certificate3[0].id" :tableId="form.certificate3[0].id" tableName="pub_certification"
                         type="cert_photo_front" :width="80" :height="80"></fileView>
              <view v-else>--</view>
              <fileView  v-if="form.certificate3[0].id" :tableId="form.certificate3[0].id" tableName="pub_certification"
                         type="cert_photo_back" :width="80" :height="80"></fileView>
              <view v-else>--</view>
            </view>
            <view v-else class="con">--</view>
          </view>

        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import {ref, reactive, defineProps} from "vue";
import publicAPI from "@/api/law/public/public";
import {onShow} from "@dcloudio/uni-app";

const {proxy} = getCurrentInstance();
const viewItem = reactive({show: false})
const form = ref({
  certificate2: [],
  certificate3: [],
})
const props = defineProps({
  schoolId: {
    type: String,
    default: null
  }
});
//获取食堂列表
let getCanteenList = async () => {
  let res = await proxy.http.asyncPost(publicAPI.getOrgCaterNoTenantIdInfo(props.schoolId));
  if (res.code === 0) {
    form.value = {...res.data};
    form.value.certificate2 = form.value.certificationList.filter(item => item.licenseTypeCode === 'certificate2')||[]
    form.value.certificate3 = form.value.certificationList.filter(item => item.licenseTypeCode === 'certificate3')||[]
  }else {
    await uni.showToast({title: res.msg, icon: 'none'});
  }
};

function retractItem() {
  viewItem.show = !viewItem.show
}

onMounted(() => {
  getCanteenList();
})
</script>

<style lang="scss" scoped>
@import "@/static/css/dailycheck/viewIndex.scss";
.title {
  width: 35vw!important;
}
</style>
